from django.urls import path, include
from rest_framework.routers import DefaultRouter
from . import views
from .comment_views import (
    CommentSubmitView, CommentCRUDView, DriverCommentListView, CommentAuditStatusView,
    AuditTaskStatusView, CommentAuditLogView, PendingCommentListView
)

router = DefaultRouter()
router.register(r'orders', views.OrderViewSet)
# 移除APIView的router注册，改为直接路径
# router.register(r'ratings', views.OrderRatingAPIView, basename='rating')
# router.register(r'complaints', views.OrderComplaintAPIView, basename='complaint')
# router.register(r'extra-fees', views.OrderExtraFeeAPIView, basename='extra-fee')

urlpatterns = [
    # 现有路由
    path('', include(router.urls)),
    path('create/', views.OrderCreateView.as_view(), name='order-create'),
    path('route/', views.RouteNavigationView.as_view(), name='route-navigation'),
    path('pay/<int:order_id>/', views.OrderPayView.as_view(), name='order-pay'),
    path('alipay/notify/', views.AlipayNotifyView.as_view(), name='alipay-notify'),
    path('manual/payment/success/', views.ManualPaymentSuccessView.as_view(), name='manual-payment-success'),
    path('accept/', views.OrderAcceptView.as_view(), name='order-accept'),
    
    # 司机相关路由
    path('driver/', views.DriverOrderView.as_view(), name='driver-orders'),
    path('driver/orders/', views.DriverOrderView.as_view(), name='driver-orders-list'),
    path('driver/orders/accept/', views.DriverOrderView.as_view(), name='driver-accept-order'),
    path('driver/daily-stats/', views.DriverDailyStatsView.as_view(), name='driver-daily-stats'),
    
    # 乘客相关路由
    path('passenger/', views.PassengerOrderView.as_view(), name='passenger-orders'),
    path('passenger/orders/', views.PassengerOrderView.as_view(), name='passenger-orders-list'),
    
    # URL别名（解决404错误）
    path('orders/', views.DriverOrderView.as_view(), name='driver-orders-alias'),
    path('daily-stats/', views.DriverDailyStatsView.as_view(), name='driver-stats-alias'),
    
    # 评价相关路由（APIView方式）
    path('ratings/', views.OrderRatingAPIView.as_view(), name='rating-list'),
    path('ratings/<int:pk>/', views.OrderRatingAPIView.as_view(), name='rating-detail'),
    path('complaints/', views.OrderComplaintAPIView.as_view(), name='complaint-list'),
    path('complaints/<int:pk>/', views.OrderComplaintAPIView.as_view(), name='complaint-detail'),
    path('extra-fees/', views.OrderExtraFeeAPIView.as_view(), name='extra-fee-list'),
    path('extra-fees/<int:pk>/', views.OrderExtraFeeAPIView.as_view(), name='extra-fee-detail'),
    
    # 评论相关路由（AI自主审核）
    path('comment/submit/', CommentSubmitView.as_view(), name='comment-submit'),
    path('comment/crud/', CommentCRUDView.as_view(), name='comment-crud'),
    path('comment/crud/<int:comment_id>/', CommentCRUDView.as_view(), name='comment-crud-detail'),
    path('comment/driver-list/', DriverCommentListView.as_view(), name='driver-comment-list'),
    path('comment/audit-status/', CommentAuditStatusView.as_view(), name='comment-audit-status'),
    path('comment/audit-task/', AuditTaskStatusView.as_view(), name='audit-task-status'),
    path('comment/audit-logs/', CommentAuditLogView.as_view(), name='comment-audit-logs'),
    path('comment/pending-list/', PendingCommentListView.as_view(), name='pending-comment-list'),
]
